<template>
  <div class="app">
    <div class="text-div" v-html="content"></div>
    <div class="return" @click="back"></div>
  </div>
</template>

<script>
import { BizMaterialController } from '@/api';
export default {
  name: 'textview',
  data() {
    return {
      sceneType: null,
      moduleType: null,
      materialType: 1,
      personnelType: null,
      content: ''
    };
  },
  methods: {
    back() {
      this.$router.replace({
        name: 'frontScene',
        query: { sceneType: this.sceneType, personnelType: this.personnelType }
      });
    },
    getFile() {
      let params = {};
      params.materialFilter = {
        sceneType: this.sceneType,
        moduleType: this.moduleType,
        materialType: this.materialType
      };
      return new Promise((resolve, reject) => {
        BizMaterialController.findByFront(this, params)
          .then(res => {
            if (res.data && res.data.length > 0) {
              this.content = res.data[0].materialContent;
            }
          })
          .catch(e => {
            reject(e);
          });
      });
    }
  },
  mounted() {
    const sceneType = this.$route.query.sceneType;
    this.sceneType = sceneType;
    const moduleType = this.$route.query.moduleType;
    this.moduleType = moduleType;
    const personnelType = this.$route.query.personnelType;
    this.personnelType = personnelType;
    this.getFile();
  }
};
</script>

<style type="scss" scoped>
.app {
  background-image: url('~@/assets/img/bg.png');
  background-size: cover;
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
  height: 100vh; /* 让父容器充满整个视口高度 */
}
.app .text-div {
  width: 80%;
  height: 70%;
  background: rgba(63, 212, 255, 0.04);
  box-shadow: inset 0px 0px 50px 20px rgba(28, 131, 193, 0.15);
  border-radius: 2px;
  border: 1px solid rgba(63, 212, 255, 0.24);
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  font-size: 20px;
  color: #e3f3ff;
  line-height: 28px;
  letter-spacing: 1px;
  text-align: left;
  font-style: normal;
  padding: 35px;
  overflow-y: auto;
}

.return {
  width: 252px;
  height: 66px;
  background-image: url('~@/assets/img/return.png');
  background-size: cover;
  position: absolute;
  bottom: 5%;
  cursor: pointer;
}
</style>
